//Source Code for Step0a



var phase0acompletearray=new Array();	//declare new array
var phase0adone;						//declare new variable
for(y=0;y<18;y++)						//declare a for loop
{
	phase0acompletearray[y]=0;			//ini phase0acompletearray array with 0s
}
phase0adone=0;							//ini phase0adone to 0
function phase0adoneChecker()
{
		phase0adone=phase0acompletearray[0]*phase0acompletearray[1]*phase0acompletearray[2]*phase0acompletearray[3]*phase0acompletearray[4]*phase0acompletearray[5]*phase0acompletearray[6]*phase0acompletearray[7]*phase0acompletearray[8]*phase0acompletearray[9]*phase0acompletearray[10]*phase0acompletearray[11]*phase0acompletearray[12]*phase0acompletearray[13]*phase0acompletearray[14]*phase0acompletearray[15]*phase0acompletearray[16]*phase0acompletearray[17];
		if (phase0adone)						// plays only if phase0adone is 1 
		{
			play();								//play animation again
		}
}
stop();									//stop animation

this.onEnterFrame=function()			//when you enter this frame
{	

//check where red_bead_1 is and compare it to where is should be in the cell and if it is set one element of the phase0acompletearray array to 1 else 0
	if(red_bead_1._x>=120&&red_bead_1._x<=250&&red_bead_1._y>=60&&red_bead_1._y<=225) 
	{
		red_bead_1._x=131.0;
		red_bead_1._y=78.0;
		phase0acompletearray[0]=1;
	}
	else
	{
		phase0acompletearray[0]=0;
	}
	
	if(red_bead_2._x>=120&&red_bead_2._x<=250&&red_bead_2._y>=60&&red_bead_2._y<=225)
	{
		red_bead_2._x=131.0;
		red_bead_2._y=90.0;
		phase0acompletearray[1]=1;
	}
	else
	{
		phase0acompletearray[1]=0;
	}

	if(red_bead_3._x>=120&&red_bead_3._x<=250&&red_bead_3._y>=60&&red_bead_3._y<=225)
	{
		red_bead_3._x=131.0;
		red_bead_3._y=102.0;
		phase0acompletearray[2]=1;
	}
	else
	{
		phase0acompletearray[2]=0;
	}

	if(red_bead_4._x>=120&&red_bead_4._x<=250&&red_bead_4._y>=60&&red_bead_4._y<=225)
	{
		red_bead_4._x=131.0;
		red_bead_4._y=114.0;
		phase0acompletearray[3]=1;
	}
	else
	{
		phase0acompletearray[3]=0;
	}
	
	if(red_cen_1._x>=120&&red_cen_1._x<=250&&red_cen_1._y>=60&&red_cen_1._y<=225)
	{
		red_cen_1._x=131.0;
		red_cen_1._y=133.0;
		phase0acompletearray[4]=1;
	}
	else
	{
		phase0acompletearray[4]=0;
	}

	if(red_bead_5._x>=120&&red_bead_5._x<=250&&red_bead_5._y>=60&&red_bead_5._y<=225)
	{
		red_bead_5._x=131.0;
		red_bead_5._y=152.0;
		phase0acompletearray[5]=1;
	}
	else
	{
		phase0acompletearray[5]=0;
	}

	if(red_bead_6._x>=120&&red_bead_6._x<=250&&red_bead_6._y>=60&&red_bead_6._y<=225)
	{
		red_bead_6._x=131.0;
		red_bead_6._y=164.0;
		phase0acompletearray[6]=1;
	}
	else
	{
		phase0acompletearray[6]=0;
	}

	if(red_bead_7._x>=120&&red_bead_7._x<=250&&red_bead_7._y>=60&&red_bead_7._y<=225)
	{
		red_bead_7._x=131.0;
		red_bead_7._y=176.0;
		phase0acompletearray[7]=1;
	}
	else
	{
		phase0acompletearray[7]=0;
	}

	if(red_bead_8._x>=120&&red_bead_8._x<=250&&red_bead_8._y>=60&&red_bead_8._y<=225)
	{
		red_bead_8._x=131.0;
		red_bead_8._y=188.0;
		phase0acompletearray[8]=1;
	}
	else
	{
		phase0acompletearray[8]=0;
	}


	if(yellow_bead_1._x>=120&&yellow_bead_1._x<=250&&yellow_bead_1._y>=60&&yellow_bead_1._y<=225)
	{
		yellow_bead_1._x=231.0;
		yellow_bead_1._y=78.0;
		phase0acompletearray[9]=1;
	}
	else
	{
		phase0acompletearray[9]=0;
	}
	
	if(yellow_bead_2._x>=120&&yellow_bead_2._x<=250&&yellow_bead_2._y>=60&&yellow_bead_2._y<=225)
	{
		yellow_bead_2._x=231.0;
		yellow_bead_2._y=90.0;
		phase0acompletearray[10]=1;
	}
	else
	{
		phase0acompletearray[10]=0;
	}

	if(yellow_bead_3._x>=120&&yellow_bead_3._x<=250&&yellow_bead_3._y>=60&&yellow_bead_3._y<=225)
	{
		yellow_bead_3._x=231.0;
		yellow_bead_3._y=102.0;
		phase0acompletearray[11]=1;
	}
	else
	{
		phase0acompletearray[11]=0;
	}

	if(yellow_bead_4._x>=120&&yellow_bead_4._x<=250&&yellow_bead_4._y>=60&&cyellow_bead_4._y<=225)
	{
		yellow_bead_4._x=231.0;
		yellow_bead_4._y=114.0;
		phase0acompletearray[12]=1;
	}
	else
	{
		phase0acompletearray[12]=0;
	}
	
	if(yellow_cen_1._x>=120&&yellow_cen_1._x<=250&&yellow_cen_1._y>=60&&yellow_cen_1._y<=225)
	{
		yellow_cen_1._x=231.0;
		yellow_cen_1._y=133.0;
		phase0acompletearray[13]=1;
	}
	else
	{
		phase0acompletearray[13]=0;
	}

	if(yellow_bead_5._x>=120&&yellow_bead_5._x<=250&&yellow_bead_5._y>=60&&yellow_bead_5._y<=225)
	{
		yellow_bead_5._x=231.0;
		yellow_bead_5._y=152.0;
		phase0acompletearray[14]=1;
	}
	else
	{
		phase0acompletearray[14]=0;
	}

	if(yellow_bead_6._x>=120&&yellow_bead_6._x<=250&&yellow_bead_6._y>=60&&yellow_bead_6._y<=225)
	{
		yellow_bead_6._x=231.0;
		yellow_bead_6._y=164.0;
		phase0acompletearray[15]=1;
	}
	else
	{
		phase0acompletearray[15]=0;
	}

	if(yellow_bead_7._x>=120&&yellow_bead_7._x<=250&&yellow_bead_7._y>=60&&yellow_bead_7._y<=225)
	{
		yellow_bead_7._x=231.0;
		yellow_bead_7._y=176.0;
		phase0acompletearray[16]=1;
	}
	else
	{
		phase0acompletearray[16]=0;
	}

	if(yellow_bead_8._x>=120&&yellow_bead_8._x<=250&&yellow_bead_8._y>=60&&yellow_bead_8._y<=225)
	{
		yellow_bead_8._x=231.0;
		yellow_bead_8._y=188.0;
		phase0acompletearray[17]=1;
	}
	else
	{
		phase0acompletearray[17]=0;
	}
	
	//multi all the elements in the phase0acompletearray array

	next_button_0b.onPress = phase0adoneChecker;//function()			//when next_button_0b is pressed 

}


//Source code for each bead and centermere in step0a
onClipEvent(mouseDown)						
{
	if(hitTest(_root._xmouse,_root._ymouse))
	{
		this.startDrag(false);
	}
}


//source code for step0b
stop();											//stop animation
next_button_1.onPress = function() 				//when next_button_1 is pressed
	{
		play();									//play animation again
	}

//source code for step1
stop();

next_button_2.onPress= function() 				//when next_button_2 is pressed
	{
		play();									//play animation again
	}

//source code for step 2
stop();												//stop animation
var phase2completearray=new Array();	//declare new array
var phase2done;
for(y=0;y<1;y++)						//declare a for loop
{
	phase0acompletearray[y]=0;			//ini phase2completearray array with 0s
}
phase2done=0;	
function phase2doneChecker()
{
		phase2done=phase2completearray[0]*phase2completearray[1];
		if (phase2done)						// plays only if phase0adone is 1 
		{
			play();								//play animation again
		}
}



this.onEnterFrame=function()
{	
//check where red_chromo_1 is
	if(red_chromo_1._x>=220&&red_chromo_1._x<=370&&red_chromo_1._y>=280&&red_chromo_1._y<=360)
	{
		red_chromo_1._x=276.1;
		red_chromo_1._y=310.0;
		phase2completearray[0]=1;
	}
	else{
		phase2completearray[0]=0;
	}
	
	if(yellow_chromo_1._x>=220&&yellow_chromo_1._x<=370&&yellow_chromo_1._y>=40&&yellow_chromo_1._y<=150)
	{
		yellow_chromo_1._x=276.1;
		yellow_chromo_1._y=95.0;
		phase2completearray[1]=1;
	}
	else{
		phase2completearray[1]=0;
	}
	next_button_3.onPress = phase2doneChecker;
	
}

//source code for each choromosome in step 2
onClipEvent(mouseDown)
{
	if(hitTest(_root._xmouse,_root._ymouse))
	{
		this.startDrag(false);
	}
}

onClipEvent(mouseUp){
	stopDrag();
}

//source code for step 3


//source code for step 4





//quiz
//layer 1
var counter=0;					//counter for correct answers pressed
this.onEnterFrame=function()			//when you enter this frame
{	
	a1.onPress = function()			//when answer button a1 is pressed 
	{
		counter = counter + 1;
		play();
	}
	b1.onPress = function()			//when answer button b1 is pressed 
	{
		play();
	}

	c1.onPress = function()			//when answer button c1 is pressed 
	{
		play();
	}

	d1.onPress = function()			//when answer button d1 is pressed 
	{
		play();
	}


	a2.onPress = function()			//when answer button a2 is pressed 
	{
		play();
	}

	b2.onPress = function()			//when answer button b2 is pressed 
	{
		counter = counter + 1;
		play();
	}

	c2.onPress = function()			//when answer button c2 is pressed 
	{
		play();
	}

	d2.onPress = function()			//when answer button d2 is pressed 
	{
		play();
	}


	a3.onPress = function()			//when answer button a3 is pressed 
	{
		play();
	}

	b3.onPress = function()			//when answer button b3 is pressed 
	{
		play();
	}

	c3.onPress = function()			//when answer button c3 is pressed 
	{
		counter = counter + 1;
		play();
	}

	d3.onPress = function()			//when answer button d3 is pressed 
	{
		play();
	}


	a4.onPress = function()			//when answer button a4 is pressed 
	{
		if(counter == 0){
			gotoAndPlay(5);
		}
		if(counter == 1){
			gotoAndPlay(16);
		}
		if(counter == 2){
			gotoAndPlay(26);
		}
		if(counter == 3){
			gotoAndPlay(36);
		}
		if(counter == 4){
			gotoAndPlay(46);
		}
	}

	b4.onPress = function()			//when answer button b4 is pressed 
	{
		if(counter == 0){
			gotoAndPlay(5);
		}
		if(counter == 1){
			gotoAndPlay(16);
		}
		if(counter == 2){
			gotoAndPlay(26);
		}
		if(counter == 3){
			gotoAndPlay(36);
		}
		if(counter == 4){
			gotoAndPlay(46);
		}
	}

	c4.onPress = function()			//when answer button c4 is pressed 
	{
		if(counter == 0){
			gotoAndPlay(5);
		}
		if(counter == 1){
			gotoAndPlay(16);
		}
		if(counter == 2){
			gotoAndPlay(26);
		}
		if(counter == 3){
			gotoAndPlay(36);
		}
		if(counter == 4){
			gotoAndPlay(46);
		}
	}

	d4.onPress = function()			//when answer button d4 is pressed 
	{
		counter = counter + 1;
		if(counter == 1){
			gotoAndPlay(16);
		}
		if(counter == 2){
			gotoAndPlay(26);
		}
		if(counter == 3){
			gotoAndPlay(36);
		}
		if(counter == 4){
			gotoAndPlay(46);
		}
	}
	done0.onPress = function(){
		getURL ("http://eden.rutgers.edu/~nakul")
	}
		done2.onPress = function(){
		getURL ("http://eden.rutgers.edu/~nakul")
	}
		done3.onPress = function(){
		getURL ("http://eden.rutgers.edu/~nakul")
	}
		done4.onPress = function(){
		getURL ("http://eden.rutgers.edu/~nakul")
	}
		done1.onPress = function(){
		getURL ("http://eden.rutgers.edu/~nakul")
	}



}

//layer 2
stop();


